package com.wgtp.ssapp.model.sideMenu;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.wgtp.ssapp.R;

public class SideMenuAdapter extends BaseAdapter {

	private LayoutInflater inflater;
	private ArrayList<SideMenuSubItem> menuItems;
	
	public SideMenuAdapter(Context ctx, ArrayList<SideMenuSubItem> menuItems) {
		inflater = LayoutInflater.from(ctx);
		this.menuItems = menuItems;
	}
	
	
	
	@Override
	public int getCount() {
		return menuItems.size();
	}

	@Override
	public Object getItem(int position) {
		
		return null;
	}

	@Override
	public long getItemId(int position) {
		
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		final ViewHolder holder;
		
		if(convertView == null || convertView instanceof TextView){
			convertView = inflater.inflate(R.layout.side_menu_sub_item, null);
			
			holder = new ViewHolder();
			holder.image = (ImageView) convertView.findViewById(R.id.rbm_item_icon);
			holder.text = (TextView) convertView.findViewById(R.id.rbm_item_text);
					
			convertView.setTag(holder);
		
		} else {
		
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.image.setImageResource(menuItems.get(position).getIcon());
		holder.text.setText(menuItems.get(position).getText());
		
		
		return convertView;
	}
	
	
	class ViewHolder {
		TextView text;
		ImageView image;
	
	}	
}
